package demo1;

/**
 * @Author: Lenovo
 * @Date: 2024/5/19 12:59
 * @description:
 */
class B {
    public B() {
        func();
    }
    public void func() {
        System.out.println("B.func()");
    }
}
class D extends B {
    private int num = 1;
    @Override
    public void func() {
        System.out.println("D.func() " + num);
    }
}
public class Test {
    public static void main(String[] args) {
        D d = new D();
    }
    /*public static void main(String[] args) {
       *//* Animal animal=new Bird("小黄",9);
        Bird bird=(Bird) animal;
        bird.fly();*//*
        Animal animal=new Bird("小黄",4);
        Bird bird=(Bird) animal;
        if(animal instanceof Bird){
            bird.fly();
        }
    }
    public static void func3(Animal animal){
        animal.eat();
    }
    public static void main3(String[] args) {
        Dog dog=new Dog("旺财",4);
        func3(dog);
        System.out.println("=======");
        Bird bird=new Bird("小黄",5);
        func3(bird);
    }
    public static Animal func2(){
        Dog dog=new Dog("旺财",4);
        return dog;
    }
    public static void func(Animal animal){

    }
    public static void main2(String[] args) {
        Dog dog=new Dog("旺财",4);
        func(dog);
        Animal animal=func2();
    }
    public static void main1(String[] args) {
        *//*Dog dog=new Dog("旺财",4);
        Animal animal=dog;*//*
        Animal animal1=new Dog("旺财",4);
    }*/
}
